
package com.tool.btn;

import java.awt.Color;
import java.awt.Font;
import java.awt.event.MouseEvent;
import org.come.Frame.NewRefiningJframe;
import org.come.Frame.PartnerArenaExchangeJframe;
import org.come.Jpanel.*;
import org.come.bean.OneArenaRole;
import org.come.model.Achieve;
import org.come.socket.Agreement;
import org.come.socket.SendMessageUntil;
import org.come.until.FormsManagement;
import org.come.until.MessagrFlagUntil;

public class PartnerArenaBtn extends MoBanBtn
{
	private int caozuo;
	private PartnerArenaMainPanel partnerArenaMainPanel;
	private PartnerArenaModelPanel partnerArenaModelPanel;
	private PartnerArenaExchangeModelPanel partnerArenaExchangeModelPanel;

	public PartnerArenaBtn(final String iconpath, final int type, final Color[] colors, final String text, final Font font, final int caozuo, final PartnerArenaMainPanel partnerArenaMainPanel) {
		super(iconpath, type, colors);
		this.setText(text);
		this.setFont(font);
		this.setVerticalTextPosition(0);
		this.setHorizontalTextPosition(0);
		this.partnerArenaMainPanel = partnerArenaMainPanel;
		this.caozuo = caozuo;
	}

	public PartnerArenaBtn(final String iconpath, final int type, final Color[] colors, final String text, final Font font, final int caozuo, final PartnerArenaModelPanel partnerArenaModelPanel) {
		super(iconpath, type, colors);
		this.setText(text);
		this.setFont(font);
		this.setVerticalTextPosition(0);
		this.setHorizontalTextPosition(0);
		this.partnerArenaModelPanel = partnerArenaModelPanel;
		this.caozuo = caozuo;
	}

	public PartnerArenaBtn(final String iconpath, final int type, final Color[] colors, final String text, final Font font, final int caozuo, final PartnerArenaExchangeModelPanel partnerArenaExchangeModelPanel) {
		super(iconpath, type, colors);
		this.setText(text);
		this.setFont(font);
		this.setVerticalTextPosition(0);
		this.setHorizontalTextPosition(0);
		this.partnerArenaExchangeModelPanel = partnerArenaExchangeModelPanel;
		this.caozuo = caozuo;
	}

	public PartnerArenaBtn(final String iconpath, final int type, final int caozuo, final PartnerArenaMainPanel partnerArenaMainPanel) {
		super(iconpath, type);
		this.partnerArenaMainPanel = partnerArenaMainPanel;
		this.caozuo = caozuo;
	}

	@Override
	public void chooseyes() {
	}

	@Override
	public void chooseno() {
	}

	@Override
	public void nochoose(final MouseEvent e) {
		if (this.caozuo == 0) {
			final String sendmes = Agreement.getAgreement().oneArenaAgreement("3");
			SendMessageUntil.toServer(sendmes);
		}
		else {
			if (this.caozuo == 1) {
				final String sendmes = Agreement.getAgreement().oneArenaAgreement("2");
				SendMessageUntil.toServer(sendmes);
			}
			else {
				if (this.caozuo == 2) {
					PartnerArenaExchangeJframe.getPartnerArenaExchangeJframe().getPartnerArenaExchangePanel().showView();
					FormsManagement.showForm(107);
				}
				else {
//					个人竞技挑战按键
					if (this.caozuo == 3) {
						final OneArenaRole oneArenaRole = this.partnerArenaModelPanel.getOneArenaRole();
						if (oneArenaRole == null) {
							return;
						}
						else {
							final String sendmes2 = Agreement.getAgreement().oneArenaAgreement("P" + oneArenaRole.getRoleId());
							SendMessageUntil.toServer(sendmes2);
						}
//						关闭活动窗口
						FormsManagement.HideForm(5);
						FormsManagement.HideForm(40);
					}
					else {
						if (this.caozuo == 4) {
							final Achieve achieve = this.partnerArenaExchangeModelPanel.getAchieve();
							if (achieve != null) {
								final String sendmes2 = Agreement.getAgreement().TaskNAgreement("R4=" + achieve.getId());
								SendMessageUntil.toServer(sendmes2);
							}
						}
						else {
							if (this.caozuo == 5) {
								final String sendmes = Agreement.getAgreement().oneArenaAgreement("4");
								SendMessageUntil.toServer(sendmes);
							}
							else {
								if (this.caozuo == 6) {
									final NewRefiningJpanel refiningJpanel = NewRefiningJframe.getNewRefiningJframe().getRefiningJpanel();
									if (!NewRefiningJframe.getNewRefiningJframe().isVisible()) {
										refiningJpanel.show(null, 4, false);
									}
								}
							}
						}
					}
				}
			}
		}
	}

	@Override
	public void mouseEntered(final MouseEvent e) {
		super.mouseEntered(e);
		if (this.caozuo == 3) {
			this.partnerArenaModelPanel.setOpaque(true);
		}
	}

	@Override
	public void mouseExited(final MouseEvent e) {
		MessagrFlagUntil.setMouse(MessagrFlagUntil.MOUSE1);
		super.mouseExited(e);
		if (this.caozuo == 3) {
			this.partnerArenaModelPanel.setOpaque(false);
		}
	}
}
